package org.hhchat.leetcode.dp;

/**
 * Created this one by HMH on 2017/6/12.
 * 答案来自leetcode
 * F(1) = 10;
 * F(2) = 9*9;
 * F(3) = F(2)*8;
 * F(4) = F(3)*7;
 * .
 * .
 * F(10) = F(9)*1;
 * F(11) = 0;
 * F(12) = 0;
 */
public class code357 {

    public static class Solution {
        public int countNumbersWithUniqueDigits(int n) {
            if (n == 0)     return 1;

            int res = 10;
            int uniqueDigits = 9;
            int availableNumber = 9;
            while (n-- > 1 && availableNumber > 0) {
                uniqueDigits = uniqueDigits * availableNumber;
                res += uniqueDigits;
                availableNumber--;
            }
            return res;
        }


    }

    public static void main(String[] args){
        Solution solution = new Solution();
        System.out.println(solution.countNumbersWithUniqueDigits(2));
    }

}
